<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>07-函数封装数组求和</title>
  </head>

  <body>
    <script>
      //1, 封装函数
      function getArrSum(arr = []) {
        let sum = 0
        for (let i = 0; i < arr.length; i++) {
          sum += arr[i]
        }
        console.log(sum)
      }
      getArrSum([1, 2, 3, 4, 5])
      getArrSum([23, 66, 88])
      getArrSum() //0
    </script>
  </body>
</html>
